using UnityEngine;
using System.Collections;

public class FadeMaterial : MonoBehaviour
{
    private Renderer _renderer;
    private void Awake()
    {
        _renderer = GetComponent<Renderer>();
    }
    private void Start()
    {
        StartCoroutine(Fade());
    }
    IEnumerator Fade()
    {
        Color c = _renderer.material.color;
        for (float alpha = 1f; alpha >= 0; alpha -= 0.1f)
        {
            c.a = alpha;
            _renderer.material.color = c;
            yield return null;
        }
    }
}
